package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type BankInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// bank--获取一条记录
func NewBankInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BankInfoLogic {
	return &BankInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *BankInfoLogic) BankInfo(req *types.BankInfoRequest) (resp *types.BankInfoResponse, err error) {
	rpcReq := rpc.BankInfoRequest{
		Id: req.Id,
	}

	rpcResp, err := l.svcCtx.AssetsRpc.TenantChannel.BankInfo(l.ctx, &rpcReq)
	if err != nil {
		return nil, err
	}

	return &types.BankInfoResponse{
		Bank: types.Bank{
			Id:           rpcResp.Id,
			CreatedAt:    rpcResp.CreatedAt,
			UpdatedAt:    rpcResp.UpdatedAt,
			Code:         rpcResp.Code,
			Phone:        rpcResp.Phone,
			MinAmount:    rpcResp.MinAmount,
			MaxAmount:    rpcResp.MaxAmount,
			DailyTimes:   rpcResp.DailyTimes,
			DailyAmount:  rpcResp.DailyAmount,
			RemainTimes:  rpcResp.RemainTimes,
			RemainAmount: rpcResp.RemainAmount,
			VisionLevel:  rpcResp.VisionLevel,
			IsDisplay:    rpcResp.IsDisplay,
			CardNumber:   rpcResp.CardNumber,
			BankNickname: rpcResp.BankNickname,
			BankName:     rpcResp.BankName,
			IfscCode:     rpcResp.IfscCode,
			Email:        rpcResp.Email,
			Province:     rpcResp.Province,
			City:         rpcResp.City,
			BranchBank:   rpcResp.BranchBank,
			IsLimit:      rpcResp.IsLimit,
			CardHolder:   rpcResp.CardHolder,
			Sort:         rpcResp.Sort,
		},
		CommonResp: types.CommonResp{
			Code:    rpcResp.CommonResp.Code,
			Message: rpcResp.CommonResp.Message,
		},
	}, nil
}
